package com.example.administrator.xjscc;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
import android.widget.Toast;

import com.example.utils.ProgressDialogUtils;
import com.example.utils.WebServiceUtils;
import com.example.utils.WebServiceUtils.WebServiceCallBack;

import org.ksoap2.serialization.SoapObject;

import java.util.HashMap;

/**
 * Created by Administrator on 2017/12/23.
 */

public class WeatherActivity extends Activity {
    private TextView tv_weather,tv_nextdayweather,tv_thirdweather;
    @Override
    protected void onCreate( Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_weather);
        tv_weather=(TextView)findViewById(R.id.tv_weather);
        tv_nextdayweather=(TextView)findViewById(R.id.tv_nextdayweather);
        tv_thirdweather=(TextView)findViewById(R.id.tv_thirdweather);

        init();
    }
    private void init() {
//        ProgressDialogUtils.showProgressDialog(this, "数据加载中...");
//        HashMap<String, String> properties = new HashMap<String, String>();
//        properties.put("theCityName", "西安");
//        WebServiceUtils.callWebService(WebServiceUtils.WEB_SERVER_URL, "getWeatherbyCityName", properties, new WebServiceCallBack() {
//            @Override
//            public void callBack(SoapObject result) {
//                ProgressDialogUtils.dismissProgressDialog();
//                if(result != null){
//                    SoapObject detail = (SoapObject) result.getProperty("getWeatherbyCityNameResult");
//                    StringBuilder sb = new StringBuilder();
//                    for(int i=0; i<detail.getPropertyCount(); i++){
//                        sb.append(detail.getProperty(i)).append("\r\n");
//                    }
//                    tv_weather.setText(sb.toString());
//                }else{
//                    Toast.makeText(WeatherActivity.this, "获取WebService数据错误", Toast.LENGTH_SHORT).show();
//                }
//            }
//        });
        String weatherinfo="天气：晴间多云\n最高温度：-9度\n最高温度：-1度\n风力：三级\n"+"风向：南风"+"湿度：41%\n"+"降雨量：0cm";
        tv_weather.setText(weatherinfo);
        tv_nextdayweather.setText(weatherinfo);
        tv_thirdweather.setText(weatherinfo);
    }
}
